/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author WMThiet
 */
public class MD5Encrypt {

    public static String MD5(String text) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(text.getBytes());
            BigInteger bis = new BigInteger(1, md5.digest());
            text = bis.toString(64);
            
        } catch (NoSuchAlgorithmException ex) {
            return "";
        }
        return text;
    }
    
    public static void main(String[] args) {
        System.out.println("Ket qua la: " + MD5("123456"));
    }
}
